home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19950929-19951130 / 000133_news@columbia.edu_Wed Oct 18 15:01:09 1995.msg < prev    next >
Internet Message Format  |  2020-01-01  |  5KB

  1. Received: from apakabar.cc.columbia.edu by watsun.cc.columbia.edu with SMTP id AA05522
  2.   (5.65c+CU/IDA-1.4.4/HLK for <kermit.misc@watsun.cc.columbia.edu>); Wed, 18 Oct 1995 11:01:16 -0400
  3. Received: by apakabar.cc.columbia.edu id AA23968
  4.   (5.65c+CU/IDA-1.4.4/HLK for kermit.misc@watsun); Wed, 18 Oct 1995 11:01:15 -0400
  5. Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
  6. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  7. Newsgroups: comp.protocols.kermit.misc
  8. Subject: Re: How can I do "Screen scraping" with C-Kermit?
  9. Date: 18 Oct 1995 15:01:09 GMT
  10. Organization: Columbia University
  11. Lines: 99
  12. Message-Id: <4634rl$ncs@apakabar.cc.columbia.edu>
  13. References: <45rqj4$ghm@its.hooked.net> <45tsp4$26k@apakabar.cc.columbia.edu> <45vfo6$8ik@its.hooked.net>
  14. Nntp-Posting-Host: watsun.cc.columbia.edu
  15. Apparently-To: kermit.misc@watsun.cc.columbia.edu
  16.  
  17. In article <45vfo6$8ik@its.hooked.net>,
  18. Byron Morgan <bmorg@hooked.net> wrote:
  19. : In <45tsp4$26k@apakabar.cc.columbia.edu>,
  20. : fdc@watsun.cc.columbia.edu (Frank da Cruz) writes:
  21. : > None of the Kermit programs presently implements this feature in
  22. : > precisely that form.  However, if you can be more specific about which
  23. : > Kermit program you are talking about, and exactly what the effect is
  24. : > you are trying to achieve, maybe we can be more helpful.
  25. : I am using OS2 CKO191(A). Using a direct RS232 connection to an old DEC
  26. : machine. The system posts subway train destination information to a
  27. : monitor screen. Each of 20 subway station platforms is represented by a
  28. : specific screen area. The application I would like to use C-Kermit for
  29. : would check the appropriate screen addresses for train information,
  30. : store the information in variables, then periodically (every 5 seconds,
  31. : for example) check each screen location for changed information. If this
  32. : can not be done with C-Kermit, I suppose it could be done with REXX,
  33. : which I have never used.
  34. Now that's a challenge.  And I take it that there is nothing in the actual
  35. text that identifies which platform the train is on -- that would make it
  36. too easy :-)  Of course, if that is true, then it is also hard to see how
  37. a textual "trigger" would have helped.  Thus you have to know the screen
  38. position of each piece of text.
  39.  
  40. OK, let's assume that the screen is updated in random fashion, but with
  41. the constraint that each platform is done all at once, as follows:
  42.  
  43.   <cursor-position-sequence><text><some-other-escape-sequence>
  44.  
  45. There are 20 positions on the screen, so you need to be able to identify
  46. twenty <cursor-position-sequence>'s.  Let's use the brute force method:
  47.  
  48.   define \%a \27[y1;x1H
  49.   define \%b \27[y2;x2H
  50.   define \%c \27[y3;x3H
  51.   ...
  52.   define \%t \27[y20;x20H
  53.  
  54. where the xn's and yn's are the column and row for each entry.  For
  55. example, if the Platform 1 text appears in column 1, row 2:
  56.  
  57.   define \%a \27[2;1H
  58.  
  59. Suppose updates occur at least every 60 seconds.  So wait for one of these
  60. sequences:
  61.  
  62.   minput 60 \%a \%b \%c ... \%t
  63.   if fail stop 1 Something bad
  64.  
  65. If updates occur at irregular intervals, then you need not be so strict:
  66.  
  67.  
  68.  
  69.   minput 60 \%a \%b \%c ... \%t
  70.   while FAILURE {
  71.     echo Nothing happening at \v(time)...,-
  72.     minput 60 \%a \%b \%c ... \%t -
  73.   }
  74.  
  75. (or just increase the INPUT timeout to some big number).
  76.  
  77. Once you get this far, the \v(minput) variable contains the number, 1-20,
  78. of item that was matched.  If the train platforms are numbered 1 through
  79. 20, you can arrange these variables correspondingly in the MINPUT command,
  80. so the \v(minput) value will be the same as the platform number.  If not,
  81. you can have a conversion function or lookup table (array).
  82.  
  83. Next, get the text:
  84.  
  85.   clear input   ; Clear out everything up to and including the escape sequence
  86.   input 10 \27  ; Wait for the next ESC
  87.   if fail stop 1 Something else bad ; Insert appropriate error handling
  88.   assign \%z \v(input) ; Get a copy of the text
  89.   assign \%z \fsubstring(\%z,\feval(\flength(\%z) - 1)) ; Discard the ESC
  90.  
  91. Now, hopefully, you have all the information you need:
  92.  
  93.  - \v(minput) contains a number 1 through 20 that tells which screen
  94.    position the text came from, from which you can deduce the platform
  95.    numbers.
  96.  
  97.  - \%z contains the corresponding text.
  98.   
  99. Let's say you also want to record the date and time that each entry was
  100. picked up.
  101.  
  102.   declare \&d[20] ; Date/time array
  103.  
  104. and then:
  105.  
  106.   assign \%d[\v(minput)] \v(date) \v(time)
  107.  
  108. Put the whole thing in a big loop, and off you go.
  109.  
  110. This is all totally untested, so you'll need to do the debugging and
  111. refinement.  Be sure to post the result!
  112.  
  113. - Frank